﻿
using HandHeldProducts.Embedded.Decoding;
using HHP.DataCollection.Decoding;

namespace OpenNETCF
{
    public class HHPDecodeAssembly : CompatibleDecodeControl
    {
        private DecodeAssembly m_decoder;

        public HHPDecodeAssembly()
        {
            m_decoder = new DecodeAssembly();
            m_decoder.DecodeEvent += new DecodeAssembly.DecodeEventHandler(m_decoder_DecodeEvent);
        }

        void m_decoder_DecodeEvent(object sender, DecodeAssembly.DecodeEventArgs e)
        {
            var msg = new DecodeMsg(
                e.Message,
                e.CodeId,
                e.AimId,
                e.AimModifier,
                e.Length,
                null); // TODO: contruct an image maybe?
            RaiseDecodeEvent(new DecodeEventArgs(msg));
        }

        public override int AimerTimeout
        {
            get { return 0; }
            set { /* nop */ }
        }

        public override bool AimIDDisplay
        {
            get { return false; }
            set { /* nop */ }
        }

        public override bool AutoLEDs
        {
            get { return false; }
            set { /* nop */ }
        }

        public override bool AutoScan
        {
            get { return false; }
            set { /* nop */ }
        }

        public override bool CodeIDDisplay
        {
            get { return false; }
            set { /* nop */ }
        }

        public override bool ModifierDisplay
        {
            get { return false; }
            set { /* nop */ }
        }

        public override TriggerKeyEnum TriggerKey
        {
            get { return TriggerKeyEnum.TK_ENTER; }
            set { /* nop */ }
        }

        public override AudioDevice AudioMode
        {
            get { return AudioDevice.SND_STANDARD; }
            set { /* nop */ }
        }

        public override bool AutoSounds
        {
            get { return false; }
            set { /* nop */ }
        }

        public override bool ContinuousScan
        {
            get { return false; }
            set { /* nop */ }
        }

        public override int DecodeAttemptLimit
        {
            get { return m_decoder.DecodeAttemptLimit; }
            set { m_decoder.DecodeAttemptLimit = value; }
        }

        public override DecodeMode DecodeMode
        {
            get { return DecodeMode.DM_STANDARD; }
            set { /* nop */ }
        }

        public override ScanLightsMode LightsMode
        {
            get { return ScanLightsMode.LM_ILLUM_AIMER; }
            set { /* nop */ }
        }

        public override int LinearRange
        {
            get { return m_decoder.LinearRange; }
            set { m_decoder.LinearRange = value; }
        }

        public override int PrintWeight
        {
            get { return m_decoder.PrintWeight; }
            set { m_decoder.PrintWeight = value; }
        }

        public override int ScanTimeout
        {
            get { return m_decoder.ScanTimeout; }
            set { m_decoder.ScanTimeout = value; }
        }

        public override int SearchTimeLimit
        {
            get { return m_decoder.SearchTimeLimit; }
            set { m_decoder.SearchTimeLimit = value; }
        }

        public override bool TraceMode
        {
            get { return false; }
            set { /* nop */ }
        }

        public override bool VideoReverse
        {
            get { return m_decoder.VideoReverse; }
            set { m_decoder.VideoReverse = value; }
        }

        public override bool VirtualKeyMode
        {
            get { return false; }
            set { /* nop */ }
        }

        public override VirtualKeyTermEnum VirtualKeyTerm
        {
            get { return VirtualKeyTermEnum.VK_NONE ; }
            set { /* nop */ }
        }


        public override void CancelScanBarcode()
        {
            m_decoder.CancelScanBarcode();
        }

        public override void Clear()
        {
            // nop
        }

        public override void ScanBarcode()
        {
            m_decoder.ScanBarcode();
        }

        public override void ScanBarcode(bool bNonBlocking)
        {
            m_decoder.ScanBarcode();
        }

        public override bool TriggerKeyIsDown()
        {
            return m_decoder.ScanInProgress;
        }

        public override void Connect()
        {
            // nop
        }

        public override void Disconnect()
        {
            // nop
        }

        public override void EnableSymbology(SymID sym, bool enable)
        {
            m_decoder.EnableSymbology((SymbologyConfigurator.Symbologies)sym, enable);
        }
    }
}
